package com.cskaoyan.controller.backStage;

import com.cskaoyan.model.Comment;
import com.cskaoyan.model.Goods;
import com.cskaoyan.model.bo.BaseParamBO;
import com.cskaoyan.model.vo.CommentDataVO;
import com.cskaoyan.model.vo.CommentRespVO;
import com.cskaoyan.model.vo.GoodsRespVO;
import com.cskaoyan.service.CommentService;
import com.cskaoyan.service.GoodsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: mall38
 * @description:
 * @author: Wang
 * @create: 2022-05-06 23:23
 **/

@RestController
@RequestMapping("admin/comment")
public class CommentController {

    @Autowired
    GoodsService goodsService;

    /*
     * description 获取评论列表
     * @author Wangtianhao
     * @date 2022-05-09 20:04
     */
    @RequiresPermissions("admin:comment:list")
    @GetMapping("list/**")
    public CommentRespVO commentsList(Integer userId, BaseParamBO param){
        CommentDataVO commentDataVO = goodsService.queryComment(userId,param);
        return CommentRespVO.ok(commentDataVO);
    }

    /*
     * description 删除评论
     * @author Wangtianhao
     * @date 2022-05-09 20:04
     */
    @RequiresPermissions("admin:comment:delete")
    @PostMapping("delete/**")
    public GoodsRespVO commentsDelete(@RequestBody Comment comments){
        Integer id = comments.getId();
        goodsService.deleteCommentById(id);
        return GoodsRespVO.ok();
    }

}
